<template>
    <div class="item-info">
      <div class="inner clearfix">
           <div class="float-left" style="width: 180px;max-height: 115px;">
               <img class="thumbs" :src="data.img" alt="img">
           </div>
          <div class="details float-left">
            <p class="title">{{data.title}}</p>
            <p class="desc" v-html="data.content">

            </p>
          <div class="option clearfix">
              <span class="time">{{data.addtime | formatDate}}</span>
              <div class="button-box">
                    <span class="btn" v-if="type ==1" @click="showd" :class="{'active':show ===true}">原因</span>
                    <span class="btn" @click ='del(data.id)'>删除</span>
                    <span class="btn">了解详情</span>
              </div>
          </div>
              <div class="reason-box" v-if="type ==1 && show === true">
                  <div class="reason">
                      <p> <span class="pink">为通过审核的原因：</span>{{data.reward}}</p>
                      <p> <span class="pink">再次强调：</span>{{data.reward}}</p>
                      <p style="text-align: right"> {{data.endtime | formatDate}}</p>
                  </div>
              </div>
          </div>
      </div>
    </div>
</template>

<script>
    /***
     * @data
     *
     */
    export default {
        name: "DiaryItem",
        props: {
          data: {
              type: Object,
          },
            type: {
              type: Number
            }
        },
        data () {
            return {
                show:false
            }
        },
        filters:{
            formatDate:function(time){
                var date = new Date(time * 1000);
                var Y = date.getFullYear() + '-';
                var M = (date.getMonth()+1 < 10 ? '0'+(date.getMonth()+1) : date.getMonth()+1) + '-';
                var D = date.getDate() + ' ';
                var h = date.getHours() + ':';
                var m = date.getMinutes() + ':';
                var s = date.getSeconds();
                return Y+M+D+h+m+s;
            },
        },
        methods :{
            showd () {
                this.show =! this.show
            },
            del(id) {
                let _this =this
                _this.$post('/api/activity/delConsultation',
                    {
                        consultation_id:id
                    }, function (res) {
                        _this.$message.success(res.msg);
                        _this.$emit('delct',1)
                    }, function (errcode, errmsg,err) {
                        console.log(err)
                        console.log(errmsg)
                    })
            }
        }
    }
</script>

<style  lang="less" scoped>
    @import "../../style/style.less";
    .item-info{
        .inner {
            padding: 20px 0;
            border-bottom: 1px dotted @border-color;
            .thumbs {
                width: 180px;
                height: 115px;
                margin-right: 26px;
            }
            .details {
                width: calc(~'100% - 210px');
                .title {
                    font-size: 16px;
                    color: #333;
                    font-weight: bold;
                    overflow: hidden;
                    white-space: nowrap;
                    text-overflow: ellipsis;
                }
                .desc {
                    font-size: 12px;
                    color: #999;
                    overflow: hidden;
                    max-height: 70px;
                    width: 458px;
                    overflow : hidden;
                    text-overflow: ellipsis;
                    display: -webkit-box;
                    -webkit-line-clamp: 3;
                    -webkit-box-orient: vertical;
                }
                .option {
                    margin-top: 15px;
                    .time {
                        color: #999;
                        margin-top: 7px;
                        display: block;
                        width: 128px;
                        float: left;
                    }
                    .button-box {
                        float: right;
                        .btn {
                            display: inline-block;
                            height: 28px;
                            line-height: 28px;
                            padding: 0 24px;
                            font-size: 14px;
                            color: #666;
                            border:1px solid @border-color;
                            border-radius: 30px;
                            margin-right: 10px;
                            cursor: pointer;
                        }
                        >:first-child:hover{
                            color: @theme-color-dark;
                            border:1px solid @theme-color-dark;
                        }
                        >:nth-child(1):hover{
                            color: @theme-color-dark;
                            border:1px solid @theme-color-dark;
                        }
                        >:nth-child(2):hover{
                            color: @theme-color-dark;
                            border:1px solid @theme-color-dark;
                        }
                        .active {
                            position: relative;
                            &:after {
                                content: '';
                                display: inline-block;
                                border: 1px solid @theme-color;
                                width: 8px;
                                height: 8px;
                                position: absolute;
                                bottom: -10px;
                                left: 28px;
                                background: #fff;
                                border-right-color: transparent;
                                border-bottom-color: transparent;
                                transform:rotate(45deg);
                                -ms-transform:rotate(45deg); 	/* IE 9 */
                                -moz-transform:rotate(45deg); 	/* Firefox */
                                -webkit-transform:rotate(45deg); /* Safari 和 Chrome */
                                -o-transform:rotate(45deg);
                            }
                        }
                    }
                }
                .reason-box {
                    padding: 5px 10px 10px;
                    width: 100%;
                    .reason {
                        padding: 10px;
                        border: 1px solid @theme-color;
                    }
                }

            }
        }
    }

</style>